import React,{ Component } from 'react'
import {
    Button,
    Row,
    Col,
    message,
} from 'antd';
import { LegionsProModal } from 'legions-pro-design';
import { bind,observer } from 'legions/store-react'
import ProjectStore from '../../stores/projectStore';
import { InstanceProModal } from 'legions-pro-design/es/LegionsProModal/interface';
import { observable,action,computed } from 'mobx';
import { observableViewModel } from 'legions/store-utils'
import CodeEditor from '../../components/codeEditor';
import { OperationEnum } from '../../constants/enum-data';
import FormPropertyConfig from '../../components/property.config.form/formPropertyConfig';
import { fullProvider,lazyInject,inject } from 'legions-control-container';
interface IProps {
    store?: ProjectStore;
    onOk: () => void;
    onCancel?: () => void;
    onReady: (value: InstanceProModal) => void
}
class ViewModel {
}
@bind({ store: ProjectStore })
@observer
export default class AddCodeExpression extends Component<IProps> {
    /** 分组信息编辑模态框实例 */
    viewModel = observableViewModel<ViewModel>(new ViewModel());
    @lazyInject(FormPropertyConfig)
    public formPropertyConfig!: FormPropertyConfig
    /** 分组信息表单实例 */
    constructor(props: IProps) {
        super(props)
        this.state = {
        }
    }
    render() {
        const formPropertyApp = this.props.store.context.formPropertyApp;
        let code = formPropertyApp.propertyFormationVM.codeValue;
        return (
            <React.Fragment>
                <LegionsProModal
                    onCancel={() => {
                        this.props.onCancel && this.props.onCancel()
                    }}
                    closable={false}
                    maskClosable={false}
                    onOk={() => {
                        this.props.onOk && this.props.onOk();
                        message.success('保存成功')
                    }}
                    onReady={(value) => {
                        const width = 850;
                        this.props.onReady && this.props.onReady(value)
                        /*  formPropertyApp.formAddCodeExpressionModalRef = value; */
                        value.viewModel.okText = '保存';
                        value.viewModel.width = width;
                    }}>
                    <React.Fragment>
                        <CodeEditor
                            width="100%"
                            height="300px"
                            mode="typescript"
                            value={code}
                            tabSize={4}
                            readOnly={formPropertyApp.propertyFormationVM.codeEditorprop.readOnly}
                            onChange={(values: string,evet) => {
                                formPropertyApp.propertyFormationVM.codeValue = values;
                            }}
                        ></CodeEditor>
                    </React.Fragment>
                </LegionsProModal>
            </React.Fragment>
        )
    }
}